package com.module.netty.handle.client;

import com.module.netty.NettyUtils;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class MessageClientHandler extends ChannelInboundHandlerAdapter {

	/**
	 * 信息读取
	 * @author chenluqiang
	 * @date 2019年3月26日 下午3:03:04 
	 *	@param ctx
	 *	@param msg
	 *	@throws Exception
	 */
	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
		System.err.println(NettyUtils.say(msg)+"——————————");
		NettyUtils.send(ctx,"this is wwwwww!");
	}

	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
		ctx.close();
		cause.printStackTrace();
	}

	@Override
	public void channelActive(ChannelHandlerContext ctx) throws Exception {
		NettyUtils.send(ctx,"this is client!");
	}
	
}
